package me.vudu.Conflict.util;


import me.vudu.Conflict.ConflictPlugin;


import org.getspout.spoutapi.gui.Color;
import org.getspout.spoutapi.gui.ContainerType;
import org.getspout.spoutapi.gui.GenericContainer;
import org.getspout.spoutapi.gui.GenericLabel;
import org.getspout.spoutapi.gui.GenericPopup;
import org.getspout.spoutapi.gui.GenericTexture;
import org.getspout.spoutapi.gui.RenderPriority;
import org.getspout.spoutapi.player.SpoutPlayer;

public class SkillGUI extends GenericPopup {

	// Get Main Class
	ConflictPlugin plugin;

	public SkillGUI(ConflictPlugin instance) {
		plugin = instance;
	}

	public SkillGUI(SpoutPlayer player, String windowTitle, String guiBackground) {

		int screenWidth = player.getMainScreen().getWidth();
		int screenHeight = player.getMainScreen().getHeight();
		int x = (screenWidth / 2) - 170;
		int y = (screenHeight / 2) - 100;
		
		

		GenericContainer buttons = new GenericContainer();
		GenericLabel title = new GenericLabel();
		WrappedGenericLabel body = new WrappedGenericLabel();
		GenericLabel copyright = new GenericLabel();
//		SelectorButton general = new SelectorButton( SelectorType.GENERAL, body);
//		SelectorButton rules = new SelectorButton( SelectorType.RULES, body);
//		SelectorButton commands = new SelectorButton( SelectorType.COMMANDS, body);
//		SelectorButton ranks = new SelectorButton( SelectorType.RANKS, body);
		ExitButton exit = new ExitButton();
		GenericTexture icons = new GenericTexture();
		GenericTexture background = new GenericTexture();

		// Button Icons
		icons.setX(x+7).setY(y+17);
		icons.setWidth(326).setHeight(20);
		icons.setUrl("https://github.com/LimeByte/SpoutHelp/raw/master/images/icons.png");
		icons.setPriority(RenderPriority.Normal);

		// Buttons
//		general.setMarginRight(4).setFixed(true);
//		rules.setMarginRight(4).setFixed(true);
//		commands.setMarginRight(4).setFixed(true);
//		ranks.setFixed(true);
		exit.setMarginLeft(214).setFixed(true);

		// Button Container
		//buttons.addChildren(general, rules, commands, ranks, exit);
		buttons.setX(x+7).setY(y+17);
		buttons.setWidth(326).setHeight(20);
		buttons.setLayout(ContainerType.HORIZONTAL);
		buttons.setAuto(false);
		
		buttons.setPriority(RenderPriority.High);

		// GUI Title
		title.setText("Skills");
		title.setX(x+7).setY(y+5);
		title.setWidth(100).setHeight(20);
		title.setFixed(false);
		title.setPriority(RenderPriority.High);

		// Body Text
		body.setX(x+10).setY(y+44);
		body.setWidth(320).setHeight(136);
		//body.setText(general.getTopicText());
		body.setDirty(true);
		body.setPriority(RenderPriority.High);

		// Copyright Text
		copyright.setTextColor(new Color("8B8B8B"));
		copyright.setShadow(false);
		copyright.setX(x+284).setY(y+186);
		copyright.setWidth(100).setHeight(18);
		copyright.setFixed(false);
		copyright.setText("SpoutHelp");
		copyright.setPriority(RenderPriority.High);

		// Main GUI
		background.setX(x).setY(y);
		background.setWidth(340).setHeight(200);
		background.setFixed(false);
		
		background.setUrl(guiBackground);
		
		
		background.setPriority(RenderPriority.Highest);

		// Attach Widgets
		this.setTransparent(true);
		this.attachWidget(plugin, background);
		this.attachWidget(plugin, title);
		this.attachWidget(plugin, body);
		this.attachWidget(plugin, copyright);
		this.attachWidget(plugin, buttons);
		this.attachWidget(plugin, icons);
	}

}